/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package WS;

import BD.Modulos.BdGuias;
import Interfaces.BdException;
import Objects.Archguid;
import Objects.Archguip_Det;
import Objects.Archguip_Pro;
import Objects.Archguip_Sum;
import Objects.Log_CGuias;
import Objects.Log_CGuias_Falt;
import Objects.Log_CGuias_Perm;
import WS.Respuestas.RespBdGuias;
import java.sql.SQLException;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
 *
 * @author armgarces
 */
@WebService(serviceName = "Guias")
public class Guias {
    public final static int CHECK_ARCHGUIE = 0;
    public final static int CHECK_ARCHGUIP = 1;
    public final static int CHECK_CGUIDE   = 2;
    /***************************************************************************/
    /********************************* GUIDE ***********************************/
    /***************************************************************************/
    /**
     * 
     * @param find
     * @param value
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "findArchguid")
    public synchronized Archguid[] findArchguid(@WebParam(name = "find")String find,
                                                @WebParam(name = "value") String value) throws BdException {
        try{
            return (Archguid[]) BdGuias.getInstance().find(new Archguid(),find, value);      
//            return archguid;
        }catch(BdException bde){
//            Gui.getInstance().ventanaError("Error Cargando Guia (Documentos): \n"+e.getMessage()); 
            //resp.setError(bde.getMessage());
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    } 
    /**
     * 
     * @param find
     * @param value
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "findArchguip_Det")
    public synchronized Archguip_Det[] findArchguip_Det(@WebParam(name = "find")String find,
                                                        @WebParam(name = "value") String value) throws BdException {
        //RespBdGuias resp = new RespBdGuias();
        try{
            return (Archguip_Det[]) BdGuias.getInstance().find(new Archguip_Det(),find, value);      
//            return archguid;
        }catch(BdException bde){
//            Gui.getInstance().ventanaError("Error Cargando Guia (Documentos): \n"+e.getMessage()); 
            //resp.setError(bde.getMessage());
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    } 
    /**
     * 
     * @param find
     * @param value
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "findArchguip_Pro")
    public synchronized Archguip_Pro[] findArchguip_Pro(@WebParam(name = "find")String find,
                                                        @WebParam(name = "value") String value) throws BdException {
        //RespBdGuias resp = new RespBdGuias();
        try{
            return (Archguip_Pro[]) BdGuias.getInstance().find(new Archguip_Pro(),find, value);      
//            return archguid;
        }catch(BdException bde){
//            Gui.getInstance().ventanaError("Error Cargando Guia (Documentos): \n"+e.getMessage()); 
            //resp.setError(bde.getMessage());
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    } 
    /**
     * 
     * @param find
     * @param value
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "findArchguip_Sum")
    public synchronized Archguip_Sum[] findArchguip_Sum(@WebParam(name = "find") String find,
                                                        @WebParam(name = "value") String value) throws BdException {
        //RespBdGuias resp = new RespBdGuias();
        try{
            return (Archguip_Sum[]) BdGuias.getInstance().find(new Archguip_Sum(),find, value);      
//            return archguid;
        }catch(BdException bde){
//            Gui.getInstance().ventanaError("Error Cargando Guia (Documentos): \n"+e.getMessage()); 
            //resp.setError(bde.getMessage());
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }  
    /**
     * @author MITM
     * @param guia
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "checkArchguie")
    public synchronized boolean checkArchguie(@WebParam(name = "guia") String guia) throws BdException {
        try{
            return BdGuias.getInstance().check(CHECK_ARCHGUIE,guia,null);                
        }catch(BdException bde){
            //resp.setError(bde.getMessage());
            throw bde;
        }catch(SQLException e){             
        }
        return false;
    }
    /**
     * @author MITM
     * @param guia
     * @param producto
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "checkArchguip")
    public synchronized boolean checkArchguip(@WebParam(name = "guia") String guia,
                                              @WebParam(name = "producto") String producto) throws BdException {
        try{
            return BdGuias.getInstance().check(CHECK_ARCHGUIP,guia,producto);                
        }catch(BdException bde){
            //resp.setError(bde.getMessage());
            throw bde;
        }catch(SQLException e){             
        }
        return false;
    }
    /**
     * @author MITM
     * @param guia
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "checkCGuias")
    public synchronized boolean checkCGuias(@WebParam(name = "guia") String guia) throws BdException {
        try{
            return BdGuias.getInstance().check(CHECK_CGUIDE,guia,null);                
        }catch(BdException bde){
            //resp.setError(bde.getMessage());
            throw bde;
        }catch(SQLException e){             
        }
        return false;
    }
    /**
     * @author MITM
     * @param user
     * @param cguias
     * @param operacion
     * @param pos
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "saveLog_CGuias")
    public synchronized RespBdGuias saveLog_CGuias(@WebParam(name = "user") String user,
                                                   @WebParam(name = "cguias") Log_CGuias cguias,
                                                    @WebParam(name = "operacion") int operacion,
                                                    @WebParam(name = "pos") int pos) throws BdException {
        RespBdGuias resp = new RespBdGuias();
        //boolean boo = Validar.validar_Save_log_CGuias(cguias);
//        boolean boo = true;
//        if (boo){
        try{                
            resp = BdGuias.getInstance().save_CGuias(user, cguias, operacion, pos);
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }       
        return resp;
    }
    /**
     * @author MITM
     * @param user
     * @param cguias
     * @param operacion
     * @param pos
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "saveCGuias_Perm")
    public synchronized boolean saveCGuias_Perm(@WebParam(name = "user") String user,
                                                @WebParam(name = "cguias") Log_CGuias_Perm cguias,
                                                @WebParam(name = "operacion") int operacion,
                                                @WebParam(name = "pos") int pos) throws BdException {
        try{                
            return BdGuias.getInstance().save_CGuias_Perm(user, cguias, operacion, pos);
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }       
        return false;
    }
    /**
     * @author MITM
     * @param user
     * @param cguias
     * @param operacion
     * @param pos
     * @return 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "saveCGuias_Falt")
    public synchronized boolean saveCGuias_Falt(@WebParam(name = "user") String user,
                                                @WebParam(name = "cguias") Log_CGuias_Falt cguias,
                                                @WebParam(name = "operacion") int operacion,
                                                @WebParam(name = "pos") int pos) throws BdException {
        try{                
            return BdGuias.getInstance().save_CGuias_falt(user, cguias, operacion, pos);
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }       
        return false;
    }
}
